<#include "../public/header.html">
    <div id="editdlg">
    </div>
    <div id="uploaddlg">
    </div>
    <div class="easyui-layout" style="width:100%;height:100%;">
        <div id="p" data-options="region:'west'" title="校区" style="width:20%;padding:10px">
            <ul id="tt" class="easyui-tree" data-options="url:'admin/class/combotree',method:'get',animate:true,onClick:tree_select,lines:true"></ul>
        </div>
        <div data-options="region:'center'" title="学生信息">
            <div id="tb" style="padding:5px 5px; border-bottom: dashed #d2d2d2 1px;margin-bottom: 5px;">
                学生名称: <input class="easyui-textbox" style="width:110px" id="student_name">
                身份证号: <input class="easyui-textbox" style="width:110px" id="student_id_cart">
                <a href="javascript://" class="easyui-linkbutton" iconCls="icon-search" onclick="search_but()">搜索</a>
            </div>
            <table id="list" class="easyui-datagrid" style="width:100%;height:100%"
                   sortName="id"
                   sortOrder="asc"
                   rownumbers="true"
                   pagination="true"
                   pagesize="50"
                   singleSelect="true"
                   data-options="url:'admin/student/listJson',toolbar:toolbar,frozenColumns:[[
                                {field:'bk_class_name',title:'班级',width:140,align:'center'},
                                {field:'student_name',title:'姓名',width:140,align:'center'},
                   ]]">
                <thead>
                <tr>
                    <th width="100" field="student_sb_cart"  align="center" sortable="true">社保卡号</th>
                    <th width="140" field="student_sb_ffd"  align="center" sortable="true">社保卡发放地</th>
                    <th width="100" field="student_id_cart"  align="center" sortable="true">身份证号</th>
                    <th width="120" field="student_sex_name" align="center" sortable="true">性别</th>
                    <th width="100" field="student_birthday"  align="center" sortable="true">出生日期</th>
                    <th width="120" field="student_hj_address_name"  align="center" sortable="true">户籍所在地</th>
                    <th width="120" field="student_hj_address_detail"  align="center" sortable="true">户籍地址</th>
                    <th width="100" field="student_hk_type_name"  align="center" sortable="true">户口性质</th>
                    <th width="100" field="student_is_marray_name"  align="center" sortable="true">婚姻状态</th>
                    <th width="120" field="student_nationality_name"  align="center" sortable="true">民簇</th>
                    <th width="120" field="student_political_name"  align="center" sortable="true">政治面貌</th>
                    <th width="120" field="at_company"  align="center" sortable="true">所在单位</th>
                    <th width="120" field="student_type_name"  align="center" sortable="true">人员类型</th>
                    <th width="120" field="app_user_type_name"  align="center" sortable="true">鉴定人员类别</th>
                    <th width="120" field="national_rank_name"  align="center" sortable="true">国家职业资格等级</th>
                    <th width="120" field="up_national_rank_name"  align="center" sortable="true">上一级职业资格级别</th>
                    <th width="120" field="is_not_testing_theory_name"  align="center" sortable="true">是否免考理论</th>
                    <th width="120" field="student_cultural_name"  align="center" sortable="true">文化程度</th>
                    <th width="120" field="student_high_school_record"  align="center" sortable="true">最高学历专业</th>
                    <th width="120" field="student_title"  align="center" sortable="true">职称</th>
                    <th width="120" field="student_duty"  align="center" sortable="true">职务</th>
                    <th width="120" field="student_age_limit"  align="center" sortable="true">职业年限</th>
                    <th width="120" field="student_duty_rank_name"  align="center" sortable="true">专业技术职务级别</th>
                    <th width="120" field="student_work_age"  align="center" sortable="true">工龄</th>
                    <th width="120" field="student_email"  align="center" sortable="true">电子邮箱</th>
                    <th width="120" field="student_address"  align="center" sortable="true">联系地址</th>
                    <th width="120" field="student_tel_phone"  align="center" sortable="true">联系电话</th>
                    <th width="120" field="student_memo_1"  align="center" sortable="true">基础信息1</th>
                    <th width="120" field="student_memo_2"  align="center" sortable="true">基础信息2</th>
                    <th width="140" field="create_time" align="center" sortable="true" data-options="formatter:function(value,row,index){
                         return formatDate(value);
                         } ">创建时间</th>
                </tr>
                </thead>
            </table>


        </div>
    </div>


    <script type="text/javascript">

        var id ;
        var dep_id;
        var down_type="";
        var class_id="";
        $(function(){
            $("#tb").prependTo(".datagrid-toolbar");
        })
        var toolbar = [{
            id:20201,
            disabled:"${((permission_button.p20201!) == 'true')? string('','true')}",
            text:'添加',
            iconCls:'icon-add',
            handler:function(){

                $("#editdlg").dialog({
                    title:"添加",
                    iconCls: 'icon-edit',
                    width: '100%',
                    height: '100%',
                    closed: false,
                    cache: false,
                    modal: true,
                    href:"admin/student/edit",
                    onLoad:function() {
                        $.messager.progress('close');
                    },
                    buttons: [{
                        text: '取消',
                        iconCls:'icon-cancel',
                        handler: function () {
                            $('#editForm').form('clear');
                            $("#editdlg").dialog("close");
                        }
                    },{
                        text: '保存',
                        iconCls: 'icon-ok',
                        handler: function () {
                            $('#editForm').form('submit',{
                                url:"admin/student/save",
                                dataType:"json",
                                onSubmit:function(){
                                    return $(this).form('enableValidation').form('validate');
                                },
                                success:function(data){
                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                    alert(data.msg);
                                    if(data.success==1){
                                        $("#editdlg").dialog("close");
                                        $("#list").datagrid("reload");
                                    }

                                }
                            });
                        }
                    }]
                });
            }
        },{
            id:20203,
            disabled:"${((permission_button.p20203!) == 'true')? string('','true')}",
            text:'导入',
            iconCls:'icon-page-excel',
            handler:function(){

                $("#uploaddlg").dialog({
                    title:"批量导入",
                    iconCls: 'icon-edit',
                    width: 500,
                    height: 300,
                    closed: false,
                    cache: false,
                    modal: true,
                    href:"admin/student/import_student",
                    onLoad:function() {
                        $.messager.progress('close');
                    },
                    buttons: [{
                        text: '取消',
                        iconCls:'icon-cancel',
                        handler: function () {
                            $('#editForm').form('clear');
                            $("#uploaddlg").dialog("close");
                        }
                    },{
                        text: '下载模板',
                        iconCls: 'icon-page-down',
                        handler: function () {
                            window.open("${root!}admin/project_file/get_model");
                        }
                    },{
                        text: '导入',
                        iconCls: 'icon-ok',
                        handler: function () {

                            $.messager.progress({text:'上传处理中....',interval:100});

                            $('#import_file_Form').form('submit',{
                                url:"admin/student/impdata_student_info",
                                dataType:"json",
                                onSubmit:function(){
                                    return $(this).form('enableValidation').form('validate');
                                },
                                success:function(data){
                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                    alert(data.msg);
                                    if(data.success==1){
                                        $("#uploaddlg").dialog("close");
                                        $("#list").datagrid("reload");
                                    }

                                    $.messager.progress('close');

                                }
                            });
                        }
                    }]
                });
            }
        },{
            id:20202,
            disabled:"${((permission_button.p20202!) == 'true')? string('','true')}",
            text:'编缉',
            iconCls:'icon-edit',
            handler:function(){
                var note =  $("#list").datagrid("getSelected");
                if(note == null){
                    $.messager.show({
                        title:'提醒',
                        msg:'请选择要编缉的行',
                        showType:'fade',
                        style:{
                            right:'',
                            bottom:''
                        }
                    });
                    return;
                }

               $("#editdlg").dialog({
                   title:"编缉",
                   iconCls: 'icon-edit',
                   width: '100%',
                   height: '100%',
                   closed: false,
                   cache: false,
                   modal: true,
                   href:"admin/student/edit?id="+note.id,
                   onLoad:function() {
                       $.messager.progress('close');
                   },
                   buttons: [{
                       text: '取消',
                       iconCls:'icon-cancel',
                       handler: function () {
                           $('#editForm').form('clear');
                           $("#editdlg").dialog("close");
                       }
                   },{
                       text: '保存',
                       iconCls: 'icon-ok',
                       handler: function () {


                           $('#editForm').form('submit',{
                               url:"admin/student/save",
                               onSubmit:function(){
                                   return $(this).form('enableValidation').form('validate');
                               },
                               success:function(data){
                                   var data = eval('(' + data + ')');  // change the JSON string to javascript object
                                   alert(data.msg);
                                   if(data.success==1){
                                       $("#editdlg").dialog("close");
                                       $("#list").datagrid("reload");
                                   }

                               }
                           });
                       }
                   }]
               });
            }
        },{
            id:20203,
            disabled:"${((permission_button.p20203!) == 'true')? string('','true')}",
            text:'批量更新',
            iconCls:'icon-page-excel',
            handler:function(){

                $("#uploaddlg").dialog({
                    title:"批量更新",
                    iconCls: 'icon-edit',
                    width: 500,
                    height: 300,
                    closed: false,
                    cache: false,
                    modal: true,
                    href:"admin/student/import_student",
                    onLoad:function() {
                        $.messager.progress('close');
                    },
                    buttons: [{
                        text: '取消',
                        iconCls:'icon-cancel',
                        handler: function () {
                            $('#editForm').form('clear');
                            $("#uploaddlg").dialog("close");
                        }
                    },{
                        text: '下载模板',
                        iconCls: 'icon-page-down',
                        handler: function () {
                            window.open("${root!}admin/project_file/get_model");
                        }
                    },{
                        text: '导入',
                        iconCls: 'icon-ok',
                        handler: function () {

                            $.messager.progress({text:'上传处理中....',interval:100});

                            $('#import_file_Form').form('submit',{
                                url:"admin/student/impdata_student_update_info",
                                dataType:"json",
                                onSubmit:function(){
                                    return $(this).form('enableValidation').form('validate');
                                },
                                success:function(data){
                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                    alert(data.msg);
                                    if(data.success==1){
                                        $("#uploaddlg").dialog("close");
                                        $("#list").datagrid("reload");
                                    }

                                    $.messager.progress('close');

                                }
                            });
                        }
                    }]
                });
            }
        },{
            id:20213,
            disabled:"${((permission_button.p20203!) == 'true')? string('','true')}",
            text:'下载',
            iconCls:'icon-page-excel',
            handler:function(){
                window.open("${root!}admin/student/download_student?student_name="+$("#student_name").val()+"&student_id_cart="+$("#student_id_cart").val()+"&dep_id="+class_id+"&type="+down_type);
            }
        },'-',{
            id:20204,
            disabled:"${((permission_button.p20204!) == 'true')? string('','true')}",
            text:'删除',
            iconCls:'icon-delete',
            handler:function(){
                var note =  $("#list").datagrid("getSelected");
                if(note == null){
                    $.messager.show({
                        title:'提醒',
                        msg:'请选择要删除的行',
                        showType:'fade',
                        style:{
                            right:'',
                            bottom:''
                        }
                    });
                    return;
                }

                $.messager.confirm('提示', '确定要删除吗？删除后无法恢复数据！', function(r){
                    if (r){
                        $.ajax({
                            type:"post",
                            url:"admin/student/drop_student",
                            data:{id:note.id},
                            dataType:"JSON",
                            success:function(data){
                                $.messager.alert("提示",data.msg);
                                $("#list").datagrid("reload");
                            }
                        })
                    }
                });
            }
        }];

        function search_but(){
           $("#list").datagrid("reload",{student_name:$("#student_name").val(),student_id_cart:$("#student_id_cart").val()});
        }

        function tree_select(note){
            dep_id = note.id;
            down_type = note.type;

            if(note.type==2){
                class_id = dep_id*1.0-note.pid*1.0-1000000;
            }else{
                class_id = dep_id
            }
            $("#list").datagrid("reload",{student_name:$("#student_name").val(),student_id_cart:$("#student_id_cart").val(),dep_id:class_id,type:note.type});
        }
    </script>
    <#include "../public/footer.html">